import numpy as np
import plotly.graph_objects as go

# 定义x和y的范围
x = np.linspace(-5, 5, 100)
y = np.linspace(-5, 5, 100)

# 计算z值：z = sin(x + y)
z = np.sin(x + y)

# 创建三维曲线
fig = go.Figure(data=[go.Scatter3d(
    x=x,
    y=y,
    z=z,
    mode='lines',
    line=dict(color='blue', width=2)
)])

# 设置布局
fig.update_layout(
    title='3D Curve: z = sin(x + y)',
    scene=dict(
        xaxis_title='X',
        yaxis_title='Y',
        zaxis_title='Z'
    ),
    width=800,
    height=600
)

# 显示图形
fig.show()
